﻿@using System.Activities.Statements
@using PagedList.Mvc
@using QAS.Nekorama.Common
@using QAS.Nekorama.Models
@using Resources
@model PagedList.IPagedList<QAS.Nekorama.Models.Question>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
@{
    ViewBag.Title = QAS_Nekorama.QUESTIONS;
}

<div id="primary">
    <div id="primary-1">
    </div>
    <!--end primary-1-->
    <div class="clear"></div>

    <div id="primary-2">
        @if (ViewBag.SearchStringParm != null)
        {
            <h3>@ViewBag.resultno @QAS_Nekorama.RESULT</h3>
        }

        <div id="question-list">
            <div class="filter">
                <ul id="filter-options">
                    <li>@Html.ActionLink(QAS_Nekorama.NEWEST, "Index", new {sortOrder = ViewBag.NewestSortParm, currentFilter = ViewBag.CurrentFilter})</li>
                    <li>@Html.ActionLink(QAS_Nekorama.FREQUENT, "Index", new {sortOrder = ViewBag.FrequentSortParm, currentFilter = ViewBag.CurrentFilter})</li>
                    <li>@Html.ActionLink(QAS_Nekorama.VOTES, "Index", new {sortOrder = ViewBag.VotesSortParm, currentFilter = ViewBag.CurrentFilter})</li>
                    <li>@Html.ActionLink(QAS_Nekorama.FEATURED, "Index", new {sortOrder = ViewBag.FeaturedSortParm, currentFilter = ViewBag.CurrentFilter})</li>
                    <li>@Html.ActionLink(QAS_Nekorama.UNANSWERED, "Index", new {sortOrder = ViewBag.UnansweredSortParm, currentFilter = ViewBag.CurrentFilter})</li>
                </ul>
            </div>
            <!--end filter-->

            @foreach (Question item in Model)
            {
                <div class="question">
                    <table>
                        <tr>
                            <td>
                                <div class="q-info">
                                    <ul>
                                        <li style="font-size: 20px; color: #cc6600;">@Helper.CountAnswer(item.QuestionID)</li>
                                        <li style="border-bottom: 1px solid #999;">@QAS_Nekorama.ANSWERS_LOWER</li>
                                        <li style="font-size: 20px; color: #cc6600;">@Html.DisplayFor(modelItem => item.VoteCount)</li>
                                        <li>@QAS_Nekorama.VOTES_LOWER</li>
                                    </ul>
                                </div>
                                <!--end q-info-->
                            </td>
                            <td>
                                <div class="q-brief">
                                    <p class="q-create-time">@item.CreatedDate.Date.Day|@item.CreatedDate.Date.Month|@item.CreatedDate.Date.Year</p>
                                    <h2>
                                        @if (item.BountyID != null && item.Bounty.Amount != 0 && item.Bounty.Answer == null)
                                        {
                                            <h2 class="bounty-n">@item.Bounty.Amount+</h2>
                                        }
                                        @if (item.Title.Length > 60)
                                        {
                                            <h2>@Html.ActionLink(item.Title.Substring(0, 60) + "...", "Details", "Question", 
                                                new {id = item.QuestionID}, new {@title = Helper.Html2Text(item.Title)})</h2>
                                        }
                                        else
                                        {
                                            <h2>@Html.ActionLink(item.Title, "Details", "Question", new {id = item.QuestionID}, 
                                                new {@title = Helper.Html2Text(item.Title)})</h2>
                                        }
                                    </h2>
                                    <p class="q-brief-content">
                                        @if (Helper.Html2Text(item.Content).Length > 120)
                                        {
                                            @Html.ActionLink(Helper.Html2Text(item.Content).Substring(0, 120) + "...", "Details", "Question", 
                                                new {id = item.QuestionID}, new {@title = Helper.Html2Text(item.Content)})
                                        }
                                        else
                                        {
                                            @Html.ActionLink(Helper.Html2Text(item.Content), "Details", "Question", 
                                                new {id = item.QuestionID}, new {@title = Helper.Html2Text(item.Content)})
                                        }
                                    </p>

                                    <div class="q-tags">
                                        <ul class="tags">
                                            @if (item.TagName1 != null && !item.TagName1.IsEmpty())
                                            {
                                                <li>@Html.ActionLink("#" + item.TagName1.Trim(), "Index", "Question", new {searchString = "#" + item.TagName1 + ": "}, null)</li>
                                            }
                                            @if (item.TagName2 != null && !item.TagName2.IsEmpty())
                                            {
                                                <li>@Html.ActionLink("#" + item.TagName2.Trim(), "Index", "Question", new {searchString = "#" + item.TagName2 + ": "}, null)</li>
                                            }
                                            @if (item.TagName3 != null && !item.TagName3.IsEmpty())
                                            {
                                                <li>@Html.ActionLink("#" + item.TagName3.Trim(), "Index", "Question", new {searchString = "#" + item.TagName3 + ": "}, null)</li>
                                            }
                                            @if (item.TagName4 != null && !item.TagName4.IsEmpty())
                                            {
                                                <li>@Html.ActionLink("#" + item.TagName4.Trim(), "Index", "Question", new {searchString = "#" + item.TagName4 + ": "}, null)</li>
                                            }
                                            @if (item.TagName5 != null && !item.TagName5.IsEmpty())
                                            {
                                                <li>@Html.ActionLink("#" + item.TagName5.Trim(), "Index", "Question", new {searchString = "#" + item.TagName5 + ": "}, null)</li>
                                            }
                                        </ul>
                                        <p class="q-view">@item.ViewCount @QAS_Nekorama.VIEW</p>
                                    </div>
                                    <!--end q-tags-->
                                </div>
                                <!--end q-brief-->
                            </td>
                        </tr>
                    </table>
                </div>
                <!--end question-->
            }
        </div>
        <!--end question-list-->
    </div>
    <!--end primary-2-->

    <div id="primary-3">
        @Html.PagedListPager(Model, page => Url.Action("Index", new {page, sortOrder = ViewBag.CurrentSort}))

        @if (User.Identity.IsAuthenticated && !Helper.IsBanned(WebSecurity.CurrentUserId))
        {
            @Html.ActionLink(QAS_Nekorama.NEW_QUESTION, "Create", null, new {@class = "newquestion-btn"})
        }
    </div>
    <!--end primary-3-->
</div>
<!--end primary-->